#ifndef MODELPLAYLISTENTRIES_H
#define MODELPLAYLISTENTRIES_H

#include <QAbstractTableModel>

#include "playlistentry.h"

class Playlist;

class ModelPlaylistEntries : public QAbstractTableModel
{
    Q_OBJECT
    Q_DISABLE_COPY(ModelPlaylistEntries)

public:
    explicit ModelPlaylistEntries(QObject *parent = 0);

    virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
    virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
    virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
    virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
    virtual QVariant headerData(int section, Qt::Orientation orientation,
                                int role = Qt::DisplayRole) const;
    virtual Qt::ItemFlags flags(const QModelIndex& index) const;
    virtual QStringList mimeTypes() const;
    virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action,
                              int row, int column, const QModelIndex &parent);

    void show(Playlist *i_pPlaylist);
    void remove(int i_idx);

    inline Playlist* playlist() const {return m_pPlaylist;}
    inline const QList<PlaylistEntry*>& entries() const {return *m_pEntries;}

signals:
    void countChanged(int);

private slots:
    void entryChanged();

private:
    enum ColumnIndex
    {
        State,
        Filename,
        Title,
        Artist,
        Album,
        Genre,
        Track,
        Year,
        MaxColIdx,
    };

    Playlist* m_pPlaylist;
    QList<PlaylistEntry*> const* m_pEntries;

    static const QBrush MISSING_BRUSH;
    static const QBrush DUPLICATE_BRUSH;
    static const QBrush INCOMPLETE_BRUSH;
    static QIcon DEFAULT_ICON;
};

#endif // MODELPLAYLISTENTRIES_H
